package com.workingpub.commons.orm;

import com.workingpub.commons.jdbc.SqlParameters;

/**
 * 封装单条SQL及关联的参数
 * 
 * @author taoping
 *
 */
public class SqlBuildEntry {
	private StringBuilder sqlContext;
	private SqlParameters sqlParameters;

	public StringBuilder getSqlContext() {
		return sqlContext;
	}

	public SqlParameters getSqlParameters() {
		return null == sqlParameters ? SqlParameters.create() : sqlParameters;
	}

	public SqlBuildEntry append(String sqlSegment) {
		if (null == sqlContext) {
			sqlContext = new StringBuilder();
		}
		if (null != sqlSegment) {
			sqlContext.append(sqlSegment);
		}
		return this;
	}

	public SqlBuildEntry putParam(String key, Object value) {
		if (null == sqlParameters) {
			sqlParameters = SqlParameters.create(key, value);
		}
		sqlParameters.put(key, value);
		return this;
	}
}
